#ifndef GIFFRAME_H
#define GIFFRAME_H

#include "gifblock.h"
#include "gifextension.h"
#include "gifimagedata.h"
#include "gifimagedescriptor.h"
#include <QColor>
#include <QList>

namespace WingGif {

typedef QColor GifColor;

class WINGEXPORT GifFrame : public GifBlock {
  Q_OBJECT
  Q_PROPERTY(GifImageDescriptor *descriptor READ descriptor)
  Q_PROPERTY(QVector<GifColor> localColorTable READ localColorTable)
  Q_PROPERTY(QList<GifExtension *> extensions READ extensions)
  Q_PROPERTY(GifImageData *imageData READ imageData)
public:
  GifImageDescriptor *descriptor();
  QVector<GifColor> localColorTable();
  QList<GifExtension *> extensions();
  GifImageData *imageData();

  GifFrame(QObject *parent = nullptr);
  GifBlockKind kind() override;
  bool read(QIODevice *stream,
            QList<GifExtension *> controlExtensions) override;

  static QVector<GifColor> readColorTable(QIODevice *stream, int size);

private:
  GifImageDescriptor *_descriptor;
  QVector<GifColor> _localColorTable;
  QList<GifExtension *> _extensions;
  GifImageData *_imageData;
};

} // namespace WingGif

#endif // GIFFRAME_H
